<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: mslaria $ ($Date: 2006/12/22 10:13:57 $)
// $RCSfile: functions_teamwork.php,v $ : $Revision: 1.3 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

/**
* Delete a link
*/
function deleteCalendarLink($linktype, $typeid)
{
	global $dbCore;

	$dbCore->query("DELETE FROM `". TABLE_PREFIX ."calendarlinks` WHERE `linktype` = '". intval($linktype) ."' AND `typeid` = '". intval($typeid) ."';");

	return true;
}

/**
* Render the Split Field View
*/
function renderSplitFields($infolist, $row1class, $row2class)
{
	if (!_is_array($infolist))
	{
		return false;
	}
	$cnt = $index = 0;
	$indexmod = count($infolist)%2;
	if ($indexmod)
	{
		$infolist[] = array("&nbsp;", "&nbsp;");
	}
	$lastindex = count($infolist)-1;
	$colarray = array();
	for ($ii=0; $ii<count($infolist); $ii++)
	{
		$colarray[$index]["align"] = "right";
		$colarray[$index]["valign"] = "top";
		$colarray[$index]["width"] = "25%";
		$colarray[$index]["nowrap"] = true;
		$colarray[$index]["value"] = '<span class="smalltext">'.$infolist[$ii][0]."</span>";
		$colarray[$index]["class"] = iif($infolist[$ii][0]=="&nbsp;", $row2class, $row1class);
		$index++;
		$colarray[$index]["align"] = "left";
		$colarray[$index]["valign"] = "top";
		$colarray[$index]["nowrap"] = true;
		$colarray[$index]["width"] = "25%";
		$colarray[$index]["value"] = '<span class="cleanrow">'.$infolist[$ii][1].'</span>';
		$colarray[$index]["class"] = $row2class;
		$cnt++; $index++;

		if ($cnt == 2 || $ii == $lastindex)
		{
			printDataRow($colarray);
			$colarray = array();
			$index = 0;
			$cnt=0;
		}
	}
}

/**
* Convert d/m/Y to Datleine
*/
function calenderDateToDateline($caldate)
{
	global $_SWIFT;
	$_date = explode("/", $caldate);
	if($_SWIFT["settings"]["dt_caltype"]=="us")
	{
		return mktime(0,0,0, intval($_date[0]), intval($_date[1]), intval($_date[2]));
	}else {
		return mktime(0,0,0, intval($_date[1]), intval($_date[0]), intval($_date[2]));
	}
	
}

/**
* Convert d/m/Y H:i to Datleine
*/
function calenderDateTimeToDateline($caldate, $caltime)
{
	global $_SWIFT;
	$_date = explode("/", $caldate);
	$_time = explode(":", $caltime);
	if($_SWIFT["settings"]["dt_caltype"]=="us")
	{
		return mktime(intval($_time[0]),intval($_time[1]),0, $_date[0], $_date[1], $_date[2]);
	}else {
		return mktime(intval($_time[0]),intval($_time[1]),0, $_date[1], $_date[0], $_date[2]);
	}
	
}
?>